# Help information for this script
proc print_help {} {
  variable script_file
  puts "\nDescription:"
  puts "Recreate a Vivado project from this script. The created project will be"
  puts "functionally equivalent to the original project for which this script was"
  puts "generated. The script contains commands for creating a project, filesets,"
  puts "runs, adding/importing sources and setting properties on various objects.\n"
  puts "Syntax:"
  puts "$script_file"
  puts "$script_file -tclargs \[--origin_dir <path>\]"
  puts "$script_file -tclargs \[--project_name <name>\]"
  puts "$script_file -tclargs \[--help\]\n"
  puts "Usage:"
  puts "Name                   Description"
  puts "-------------------------------------------------------------------------"
  puts "\[--origin_dir <path>\]  Determine source file paths wrt this path. Default"
  puts "                       origin_dir path value is \".\", otherwise, the value"
  puts "                       that was set with the \"-paths_relative_to\" switch"
  puts "                       when this script was generated.\n"
  puts "\[--project_name <name>\] Create project with the specified name. Default"
  puts "                       name is the name of the project from where this"
  puts "                       script was generated.\n"
  puts "\[--help\]               Print help information for this script"
  puts "-------------------------------------------------------------------------\n"
  exit 0
}

set a 123

# 向 tcl 送入变量的解析
if { $::argc > 0 } {
  for {set i 0} {$i < $::argc} {incr i} {
    set option [string trim [lindex $::argv $i]]
    switch -regexp -- $option {
      "--project"         { incr i; set project [lindex $::argv $i] }
      "--board"           { incr i; set board [lindex $::argv $i] }
      "--standalone"      { incr i; set standalone [lindex $::argv $i] }
      "--help"            { print_help }
      default {
        if { [regexp {^-} $option] } {
          puts "ERROR: Unknown option '$option' specified, please type '$script_file -tclargs --help' for usage info.\n"
          return 1
        }
      }
    }
  }
}

# 获取脚本所在路径
set script_dir  [ file dirname [ file normalize [ info script ] ] ]

# ROOT 所在路径
set root_dir  [ file normalize "$script_dir/../.." ]

# 所有工程所在文件夹
set builds_dir  [ file normalize "$root_dir/build" ]
puts $builds_dir

# 加载板级信息
switch $board {
  zed { 
    puts "$board not supported now" 
  }
  pynq {
    source pynq.tcl
    # exec cp [file normalize "$root_dir/NutShell/src/test/vsrc/monitor.v"] $builds_dir
    set src_files [list \
      "[file normalize "$root_dir/NutShell/src/test/vsrc/monitor.v"]" \
    ]
    puts $src_files
  }
  default { 
    puts "$board not supported now" 
  }
}